<style type="text/css">
 .img-review {width:250px;height: auto;}
</style>
<script type="text/javascript">
Do('base','layer','form','date',function () {
    $('#form').isForm({'upload':'{:url("system/passport.common/upload")}'});
    $(".win").win({'url':'{:url("popupshop/SaleHouse/select")}'});
    //增加商品属性
    var i = {$i};
    $('#add').click(function () {
        i++;
        $("#gift").append('<tr><th></th><td class="input-group">' +
            '<input autocomplete="off" onClick="winGift('+ i +')" datatype="n" class="readonly input gift_house_id_'+i+'" type="text" name="gift[house_id][]" />' +
            '<input autocomplete="off" id="gift_cost_price_'+ i +'"  datatype="npot" class="input" type="text" name="gift[cost_price][]" />' +
            '<input autocomplete="off" id="gift_entrust_price_'+ i +'"  datatype="npot" class="input n-bln" type="text" name="gift[entrust_price][]" />' +
            '<input autocomplete="off" datatype="npot" class="input" type="text" name="gift[sale_price][]" /></div>' +
            '<div class="fn-left w50 fn-tac fn-cp" onClick="delGift(this)"><i class="iconfont icon-reduce_icon"></i></td></tr>'
        )
    })
})
//删除属性
function winGift(id) {
    openwin('{:url("popupshop/SaleHouse/select")}?input='+id);
}
//删除属性
function delGift(dom) {
    $(dom).parents("tr").remove();
    $(dom).parent().remove();
}
//添加图片
function setImg(show_src){
    $("#img").val(show_src);
    $(".img-review").html('<img src="'+show_src+'">');  
}
//销售商品
function items(ids,dom){
    $.getJSON("{:url('popupshop/SaleHouse/getView')}",{id:ids},function(rel){
        if('house_id' == dom){
            $("#house_id").val(ids);
            $("#cost_price").val(rel.data.cost_price);
            $("#entrust_price").val(rel.data.sell_price);
        }else{
            $(".gift_house_id_"+dom).val(ids);
            $("#gift_cost_price_"+dom).val(rel.data.cost_price);
            $("#gift_entrust_price_"+dom).val(rel.data.sell_price);
        }
    });
}
</script>